//
//  HZLoginVc.m
//  MyDoctor
//
//  Created by 黑眼圈 on 16/5/4.
//  Copyright © 2016年 heiyan. All rights reserved.
//登录

#import "HZLoginVc.h"

@interface HZLoginVc ()

@property(nonatomic,strong)UIImageView*  icon;
@property(nonatomic,strong)UIImageView*  textImg;
@property(nonatomic,strong)HZLoginField*  numField;
@property(nonatomic,strong)HZLoginField*  passField;

@property(nonatomic,strong)UIButton*  noteBtn;
@property(nonatomic,strong)UIButton*  loginBtn;
@property(nonatomic,strong)UIButton*  registerBtn;
@property(nonatomic,strong)UIButton*  forgetBtn;

@property(nonatomic,strong)UIView*  wireView;

@end

@implementation HZLoginVc

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置并添加子控件
    [self setupUI];
    
    
}

#pragma mark -
#pragma mark    设置并添加子控件
-(void)setupUI{
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"用户登录";
    
    //添加
    [self.view addSubview:self.icon];
    [self.view addSubview:self.textImg];
    [self.view addSubview:self.numField];
    [self.view addSubview:self.passField];
    [self.view addSubview:self.noteBtn];
    [self.view addSubview:self.loginBtn];
    [self.view addSubview:self.registerBtn];
    [self.view addSubview:self.forgetBtn];
    [self.view addSubview:self.wireView];
    
    
    //约束
    [self.icon makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.view);
        make.top.equalTo(60);
    }];
    
    [self.textImg makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.icon);
        make.top.equalTo(self.icon.bottom);
        
    }];
    
    
    [self.numField makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.icon);
        make.width.equalTo(300);
        make.top.equalTo(self.textImg.bottom).offset(30);
        make.height.equalTo(30);
    }];
    
    [self.passField makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.icon);
        make.width.equalTo(300);
        make.top.equalTo(self.numField.bottom).offset(20);
        make.height.equalTo(30);
    }];
    
    [self.noteBtn makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.passField.bottom).offset(25);
        make.centerX.equalTo(self.icon);
        
    }];
    
    [self.loginBtn makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.icon);
        make.width.equalTo(300);
        make.top.equalTo(self.noteBtn.bottom).offset(20);
        
    }];
    
    [self.registerBtn makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.icon).equalTo(-60);
        make.top.equalTo(self.loginBtn.bottom).equalTo(100);
    }];
    
    [self.forgetBtn makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.icon).equalTo(60);
        make.top.equalTo(self.loginBtn.bottom).equalTo(100);
    }];
    
    [self.wireView makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.icon);
        make.top.equalTo(self.forgetBtn);
        make.width.equalTo(1);
        make.height.equalTo(30);
    }];
    
}





#pragma mark -
#pragma mark     点击登录的方法
-(void)login{
    
    
    
    
}




#pragma mark -
#pragma mark     懒加载子控件
-(UIImageView *)icon{
    if (!_icon) {
        
        _icon = [[UIImageView alloc]init];
        _icon.image = [UIImage imageNamed:@"product_img_logo_nor.png"];
        [_icon sizeToFit];
    }
    
    return _icon;
}

-(UIImageView *)textImg{
    if (!_textImg) {
        
        _textImg = [[UIImageView  alloc]init];
        _textImg.image = [UIImage imageNamed:@"product_text_logo_nor.png"];
        [_textImg sizeToFit];
    }
    return _textImg;
}


-(UIView *)wireView{
    if (!_wireView) {
        
        _wireView = [[UIView alloc]init];
        
        _wireView.backgroundColor = [UIColor grayColor];

    }
    return _wireView;
}

-(HZLoginField *)numField{
    if (!_numField) {
        
        _numField = [[HZLoginField alloc]init];
        _numField.placeholder = @"请输入您的手机号码";
        
        _numField.layer.borderColor = [UIColor colorWithWhite:202/255.0 alpha:1].CGColor;
        _numField.layer.borderWidth = 1;
        _numField.layer.cornerRadius = 5;
        _numField.layer.masksToBounds = YES;
        
        //设置左右视图
        _numField.leftViewMode = UITextFieldViewModeAlways;
        _numField.rightViewMode = UITextFieldViewModeAlways;
   
   
        
        //设置占位文本的大小
        [_numField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];

        //设置光标的位置
        [_numField editingRectForBounds:CGRectMake(20, 20, 0, 0)];

     

    }
    return _numField;
}



-(HZLoginField *)passField{
    if (!_passField) {
        
        _passField = [[HZLoginField alloc]init];
        _passField.placeholder = @"请输入您的登录密码";
        
        _passField.layer.borderColor = [UIColor colorWithWhite:202/255.0 alpha:1].CGColor;
        _passField.layer.borderWidth = 1;
        _passField.layer.cornerRadius = 5;
        _passField.layer.masksToBounds = YES;
        
        //设置左右视图
        _passField.leftViewMode = UITextFieldViewModeAlways;
        _passField.rightViewMode = UITextFieldViewModeAlways;
        
        //设置占位文本的大小
        [_passField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];
        
        //设置光标的位置
        [_passField editingRectForBounds:CGRectMake(20, 20, 0, 0)];
    }
    return _passField;
}

-(UIButton *)noteBtn{
    if (!_noteBtn) {
        
        _noteBtn = [[UIButton alloc]init];
        
        [_noteBtn setTitle:@"通过短信验证码登录" forState:UIControlStateNormal];
        _noteBtn.titleLabel.font = [UIFont systemFontOfSize:13];
        [_noteBtn setTitleColor:[UIColor colorWithRed:0/255.0 green:118/255.0 blue:255/255.0 alpha:1] forState:UIControlStateNormal];
    }
    return _noteBtn;
}

-(UIButton *)loginBtn{
    if (!_loginBtn) {
        
        _loginBtn = [[UIButton alloc]init];
        
        //监听按钮点击
        [_loginBtn addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside];
        
        [_loginBtn setTitle:@"登录" forState:UIControlStateNormal];
        [_loginBtn setBackgroundColor:[UIColor colorWithRed:0/255.0 green:198/255.0 blue:199/255.0 alpha:1]];
    }
    return _loginBtn;
}

-(UIButton *)registerBtn{
    if (!_registerBtn) {
        
        _registerBtn = [[UIButton alloc]init];
        
        [_registerBtn setTitle:@"注册新账号" forState:UIControlStateNormal];
        _registerBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_registerBtn setTitleColor:[UIColor colorWithRed:0/255.0 green:118/255.0 blue:255/255.0 alpha:1] forState:UIControlStateNormal];
    }
    return _registerBtn;
}

-(UIButton *)forgetBtn{
    if (!_forgetBtn) {
        
        _forgetBtn = [[UIButton  alloc]init];
        
        [_forgetBtn setTitle:@"忘记密码" forState:UIControlStateNormal];
        _forgetBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_forgetBtn setTitleColor:[UIColor colorWithRed:0/255.0 green:118/255.0 blue:255/255.0 alpha:1] forState:UIControlStateNormal];
    }
    return _forgetBtn;
}







@end
